﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Scrt;
using Excel = Microsoft.Office.Interop.Excel;
using ExcelAddIn2010.ExcelOp;
using System.Reflection;
using System.Windows.Forms;
using System.Diagnostics;
using DalMgr;
namespace ExcelAddIn2010
{
    public class SoftMgr
    {
        public SoftMgr()
        {
            gValue.ExcelApp = Globals.ThisAddIn.Application;
            gValue.SftwareDownloadUrl = SftDataMgr.ReadStr(gValue.SFT_CFG, gValue.SFT_CFG_DOWNLOAD_URL, "");
        }
        ~SoftMgr()
        {
            gValue.ExcelApp = null;
        }
        public void ShowRegForm()
        {
            using (FrmRegister frm = new FrmRegister(gValue.softReg))
            {
                frm.ShowDialog();
            }
        }
        public void DeleteBlankRows()
        {
            Excel.Worksheet wkSht = gValue.ExcelApp.ActiveSheet;
            WorksheetOp.DeleteBlankRows(wkSht);
        }
        public void DeleteBlankSheets()
        {
            Excel.Workbook wkBk = gValue.ExcelApp.ActiveWorkbook;
            WorkbookOp.DeleteBlankSheets(wkBk);
        }
        public void DeleteSheets()
        {
            using(FrmDeleteWksht frm = new FrmDeleteWksht())
            {
                frm.ShowDialog();
            }
        }
        public void OpenHomeUrl()
        {
            gValue.softReg.ShowHomePage();  
        }
        public void ShowAuthor()
        {
            string strInfo = "";
            Assembly AppAssembly = Assembly.GetExecutingAssembly();
            string strVer = string.Format("{0}", AppAssembly.GetName().Version);

            strInfo = "作者：我是菜鸟\n版本：" + strVer;
            MessageBox.Show(strInfo, gValue.MSG_TITLE);
        }
        public void OpenUrl(string strUrl)
        {
            Process.Start(strUrl);
        }
    }
}
